<%@ Control Language="C#" AutoEventWireup="true"
	Inherits="System.Web.Mvc.ViewUserControl<MindMelder.Core.User>" %>
<%@ Import Namespace="MindMelder.Core" %>

<script type="text/javascript">
	$(function() {
		
		$('#User_BirthDate').datepicker({
			changeYear: true,
			changeMonth: true,
			minDate: new Date(1900, 1, 1, 1),
			maxDate: "-1d",
			defaultDate: "-30y",
			dateFormat: 'yy-mm-dd'
		});
	});
</script>

<%= Html.ValidationSummary() %>

<% using (Html.BeginForm()) { %>
    <%= Html.AntiForgeryToken() %>
    <%= Html.Hidden("id", (ViewData.Model != null) ? ViewData.Model.Id : 0) %>

    <ul>
		<li>
			<label for="User.FirstName">FirstName:</label>
			<div>
				<%= Html.TextBox("User.FirstName", 
					(ViewData.Model != null) ? ViewData.Model.FirstName : "")%>
			</div>
			<%= Html.ValidationMessage("User.FirstName")%>
		</li>
		<li>
			<label for="User.LastName">LastName:</label>
			<div>
				<%= Html.TextBox("User.LastName", 
					(ViewData.Model != null) ? ViewData.Model.LastName : "")%>
			</div>
			<%= Html.ValidationMessage("User.LastName")%>
		</li>
		<li>
			<label for="User.Country">Country:</label>
			<div>
				<%= Html.TextBox("User.Country", 
					(ViewData.Model != null) ? ViewData.Model.Country : "")%>
			</div>
			<%= Html.ValidationMessage("User.Country")%>
		</li>
		<li>
			<label for="User.State">State:</label>
			<div>
				<%= Html.TextBox("User.State", 
					(ViewData.Model != null) ? ViewData.Model.State : "")%>
			</div>
			<%= Html.ValidationMessage("User.State")%>
		</li>
		<li>
			<label for="User.BirthDate">Birthday:</label>
			<div>
				<%= Html.TextBox("User.BirthDate", 
					(ViewData.Model != null) ? ViewData.Model.BirthDate.ToString("yyyy/MM/dd") : "")%>
			</div>
			<%= Html.ValidationMessage("User.BirthDate")%>
		</li>
		<li>
			<label for="User.OpenId">OpenId:</label>
			<div>
				<%= Html.TextBox("User.OpenId", 
					(ViewData.Model != null) ? ViewData.Model.OpenId : "")%>
			</div>
			<%= Html.ValidationMessage("User.OpenId")%>
		</li>
	    <li>
            <%= Html.SubmitButton("btnSave", "Save") %>
	        <%= Html.Button("btnCancel", "Cancel", HtmlButtonType.Button,
									"window.location.href = '" + ResolveUrl("~") + "Users/MyProfile';")%>
        </li>
    </ul>
<% } %>
